/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cse308.helper_classes;

import cse308.General;
import cse308.GeneralEntity;
import cse308.entities.Studentoutcome;
import cse308.entities.Targetsurveyassessment;
import cse308.entities.Targetdirectassessment;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;

/**
 *
 * @author Aaron
 */
public class StudentOutcomeClass implements GeneralTest {

    private String identifier;
    private int sequenceNumber;
    private String shortName;
    private String description;
    private Map<String, Object> targetDirectAssessmentAttainmentLevel;
    private Map<String, Object> targetSurveyAssessmentAttainmentLevel;
    private String currentSemesterTDAA;
    private String currentSemesterTSAA;
    private int currentDirectAssessment;
    private int currentSurveyAssessment;

    public StudentOutcomeClass(Studentoutcome entity) {
        this.identifier = entity.getIdentifier();
        this.sequenceNumber = entity.getSequencenumber();
        this.shortName = entity.getShortname();
        this.description = entity.getDescription();
        this.targetDirectAssessmentAttainmentLevel = new HashMap();
        this.targetSurveyAssessmentAttainmentLevel = new HashMap();
    }

    @Override
    public String getIdentifier2() {
        return identifier;
    }
    public String getIdentifier(){
        return identifier;
    }
    public void setIdentifier(String identifier) {
        this.identifier = identifier;
    }

    public int getSequenceNumber() {
        return sequenceNumber;
    }

    public void setSequenceNumber(int sequenceNumber) {
        this.sequenceNumber = sequenceNumber;
    }

    public String getShortName() {
        return shortName;
    }

    public void setShortName(String shortName) {
        this.shortName = shortName;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Map<String, Object> getTargetDirectAssessmentAttainmentLevel() {
        return targetDirectAssessmentAttainmentLevel;
    }

    public void setTargetDirectAssessmentAttainmentLevel(Map<String, Object> targetDirectAssessmentAttainmentLevel) {
        this.targetDirectAssessmentAttainmentLevel = targetDirectAssessmentAttainmentLevel;
    }

    public Map<String, Object> getTargetSurveyAssessmentAttainmentLevel() {
        return targetSurveyAssessmentAttainmentLevel;
    }

    public void setTargetSurveyAssessmentAttainmentLevel(Map<String, Object> targetSurveyAssessmentAttainmentLevel) {
        this.targetSurveyAssessmentAttainmentLevel = targetSurveyAssessmentAttainmentLevel;
    }

    public String getCurrentSemesterTDAA() {
        return currentSemesterTDAA;
    }

    public void setCurrentSemesterTDAA(String currentSemesterTDAA) {
        this.currentSemesterTDAA = currentSemesterTDAA;
    }

    public String getCurrentSemesterTSAA() {
        return currentSemesterTSAA;
    }

    public void setCurrentSemesterTSAA(String currentSemesterTSAA) {
        this.currentSemesterTSAA = currentSemesterTSAA;
    }

    public int getCurrentDirectAssessment() {
        return currentDirectAssessment;
    }

    public void setCurrentDirectAssessment(int currentDirectAssessment) {
        this.currentDirectAssessment = currentDirectAssessment;
    }

    public int getCurrentSurveyAssessment() {
        return currentSurveyAssessment;
    }

    public void setCurrentSurveyAssessment(int currentSurveyAssessment) {
        this.currentSurveyAssessment = currentSurveyAssessment;
    }

    public void setDirectWithQuery(EntityManager em) {
        Query relevantDirectAttainment = em.createNamedQuery("Targetdirectassessment.findAll");
        List<Targetdirectassessment> tal = relevantDirectAttainment.getResultList();
        for (Targetdirectassessment i : tal) {
            if (i.getTargetdirectassessmentPK().getStudentoutcome().equals(this.identifier)) {
                String keyvalue = i.getTargetdirectassessmentPK().getSemester() + " " + i.getAttainmentlevel();
                targetDirectAssessmentAttainmentLevel.put(keyvalue, keyvalue);
            }
        }
    }

    public void setSurveyWithQuery(EntityManager em) {
        Query relevantSurveyAttainment = em.createNamedQuery("Targetsurveyassessment.findAll");
        List<Targetsurveyassessment> tsl = relevantSurveyAttainment.getResultList();
        for (Targetsurveyassessment i : tsl) {
            if (i.getTargetsurveyassessmentPK().getStudentoutcome().equals(this.identifier)) {
                String keyvalue = i.getTargetsurveyassessmentPK().getSemester() + " " + i.getAttainmentlevel();
                this.targetSurveyAssessmentAttainmentLevel.put(keyvalue, keyvalue);
            }
        }
    }

  
    @Override
    public ArrayList<Map<String, General>> getMap() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public ArrayList<List<String>> getList() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public GeneralEntity findCorrespondingEntity() {
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("CSE_308_ABETPU");
        EntityManager em = emf.createEntityManager();
        return em.find(Studentoutcome.class, this.identifier);
    }

    @Override
    public boolean equalsEntity(GeneralEntity toEqual) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

   // @Override
    public void updateRelationship(GeneralEntity ge1) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
}